export default async(tmplIds)=>{//传入tmplId，检测用户是否开放权限，允许推送消息
  return new Promise((resolve,reject)=>{
    wx.getSetting({
      withSubscriptions: true,
      success(res){
        if(res.subscriptionsSetting.itemSettings!=undefined){
          var flag = res.subscriptionsSetting.itemSettings[tmplIds[0]]
        }else{
          var flag = undefined
        }
        
        if(flag==undefined){
            wx.requestSubscribeMessage({
              tmplIds: tmplIds,
              success(res){
                //点击完成后就返回成功就行
              },
              complete(){
                resolve(true)
            }
            })
        }else if(flag!='accept'){
          wx.requestSubscribeMessage({
            tmplIds: tmplIds,
            success(res){
              resolve(true)//点击完成后就返回成功就行
            },
            complete(){
                resolve(true)
            }
          })
        }else{//直接返回true,原本以为用户选择一直同意之后，就可以一直推送，这里是一个bug
          wx.requestSubscribeMessage({ 
            tmplIds: tmplIds,
            success(res){
              resolve(true)//点击完成后就返回成功就行
            },
            complete(){
              resolve(true)
          }
          }) 
        }
      }
    })
  })
}